//
// Created by liushuai on 2021/1/8.
//

#include "splitString.h"
<<<<<<< HEAD:cxx/algorithm/src/splitString.cc
vector<string> splitString(string originString,string splitSymble){
    vector<string> result;
    int size = originString.size();
    int split_size = splitSymble.size();
    if(size == 0)
        result.push_back(originString);
    else{

        int start = 0;
        int end = 0;
        string sub = originString.substr(start,end);

        for(int i=0;i<size;i++){

            if(splitSymble[0] == originString[i] && splitSymble == originString.substr(i,split_size)){
                string temp = originString.substr(i,split_size);
//                if(splitSymble == temp){
//                    sub = originString.substr(start,end-start);
//                    result.push_back(sub);
//
//
//                }
                result.push_back(sub);
                start = i+splitSymble.size();
                end = start;
                i = start-1;


            }else if(end == size-1){
                sub = originString.substr(start,end-start+1);
                result.push_back(sub);
            }
            else{
                end++;
                sub = originString.substr(start,end);
//       cout<<"end str:"<<sub<<endl;
            }
        }
    }

    return result;
=======
vector<string> splitString(string originString, string splitSymble) {
  vector<string> result;
  int size = originString.size();
  int split_size = splitSymble.size();
  if (size == 0)
    result.push_back(originString);
  else {
    int start = 0;
    int end = 0;
    string sub = originString.substr(start, end);

    for (int i = 0; i < size; i++) {
      if (splitSymble[0] == originString[i] &&
          splitSymble == originString.substr(i, split_size)) {
        string temp = originString.substr(i, split_size);
        //                if(splitSymble == temp){
        //                    sub = originString.substr(start,end-start);
        //                    result.push_back(sub);
        //
        //
        //                }
        result.push_back(sub);
        start = i + splitSymble.size();
        end = start;
        i = start - 1;

      } else if (end == size - 1) {
        sub = originString.substr(start, end - start + 1);
        result.push_back(sub);
      } else {
        end++;
        sub = originString.substr(start, end);
        //       cout<<"end str:"<<sub<<endl;
      }
    }
  }

  return result;
>>>>>>> dev:cxx/algorithm/common/src/splitString.cc
}
